package com.ruoyi.hqfinance.service.impl;

import com.github.pagehelper.PageHelper;
import com.ruoyi.hqfinance.domain.HqPaiFeeSubjectByPay;
import com.ruoyi.hqfinance.domain.HqPaiFeeSubjectByReceive;
import com.ruoyi.hqfinance.domain.vo.HqPaiFeeSubjectByPayVo;
import com.ruoyi.hqfinance.domain.vo.HqPaiFeeSubjectByReceiveVo;
import com.ruoyi.hqfinance.mapper.HqPaiFeeSubjectByPayMapper;
import com.ruoyi.hqfinance.mapper.HqPaiFeeSubjectByReceiveMapper;
import com.ruoyi.hqfinance.service.HqPaiFeeSubjectService;
import com.ruoyi.logistic.domain.PageDate;
import com.ruoyi.logistic.mapper.NetworkNameMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class HqPaiFeeSubjectServiceImpl implements HqPaiFeeSubjectService {
    @Autowired
    private HqPaiFeeSubjectByReceiveMapper hqPaiFeeSubjectByReceiveMapper;
    @Autowired
    private HqPaiFeeSubjectByPayMapper hqPaiFeeSubjectByPayMapper;
    @Autowired
    private NetworkNameMapper networkNameMapper;

    @Override
    public List<HqPaiFeeSubjectByReceive> paiFeeSubjectByDayByReceive(HqPaiFeeSubjectByReceiveVo hqPaiFeeSubjectByReceiveVo) {
        PageHelper.startPage(hqPaiFeeSubjectByReceiveVo.getPageDate());
        List<HqPaiFeeSubjectByReceive> paiFeeSubjectByReceives = hqPaiFeeSubjectByReceiveMapper.paiFeeSubjectByReceive(hqPaiFeeSubjectByReceiveVo);
        assert paiFeeSubjectByReceives != null;
        for (HqPaiFeeSubjectByReceive hqPaiFeeSubjectByReceive : paiFeeSubjectByReceives) {
            if (hqPaiFeeSubjectByReceiveVo.getCollectType() == 2) {
                hqPaiFeeSubjectByReceive.setDate(hqPaiFeeSubjectByReceiveVo.getStartTime() + "至" +hqPaiFeeSubjectByReceiveVo.getEndTime());
            }
            hqPaiFeeSubjectByReceive.setNetworkNameId(networkNameMapper.selectCodeByName(hqPaiFeeSubjectByReceive.getNetworkName()));
        }
        return paiFeeSubjectByReceives;
    }

    @Override
    public List<HqPaiFeeSubjectByPay> paiFeeSubjectByPay(HqPaiFeeSubjectByPayVo hqPaiFeeSubjectByPayVo) {
        PageHelper.startPage(hqPaiFeeSubjectByPayVo.getPageDate());
        List<HqPaiFeeSubjectByPay> paiFeeSubjectByPays = hqPaiFeeSubjectByPayMapper.paiFeeSubjectByPay(hqPaiFeeSubjectByPayVo);
        assert paiFeeSubjectByPays != null;
        for (HqPaiFeeSubjectByPay hqPaiFeeSubjectByPay : paiFeeSubjectByPays) {
            if (hqPaiFeeSubjectByPayVo.getCollectType() == 2) {
                hqPaiFeeSubjectByPay.setDate(hqPaiFeeSubjectByPayVo.getStartTime() + "至" +hqPaiFeeSubjectByPayVo.getEndTime());
            }
            if (hqPaiFeeSubjectByPayVo.getDisplayLevel() == 2){
                hqPaiFeeSubjectByPay.setNetworkCode("124000");
                hqPaiFeeSubjectByPay.setName("辽宁盘锦公司");
            }
        }
        return paiFeeSubjectByPays;
    }
}
